package com.example.application.views;

import com.example.application.views.change.ChangeView;
import com.example.application.views.change.Decimal_Conversion;
// import com.example.application.security.SecurityService;
import com.example.application.views.list.ListView;
import com.vaadin.flow.component.applayout.AppLayout;
import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.HighlightConditions;
import com.vaadin.flow.router.RouterLink;

public class MainLayout extends AppLayout {
    // private final SecurityService securityService;

    public MainLayout() {

        // this.securityService = securityService;
        createHeader();
        createDrawer();
    }

    private void createHeader() {
        H1 logo = new H1("个人混合Web工具项目");
        logo.addClassNames("text-l", "m-m");

        // Button logout = new Button("登出", e->System.out.print(e));

        HorizontalLayout header = new HorizontalLayout(new DrawerToggle(), logo);

        header.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.CENTER);
        header.expand(logo);
        header.setWidth("100%");
        header.addClassNames("py-0", "px-m");

        addToNavbar(header);

    }

    private void createDrawer() {
        RouterLink listLink = new RouterLink("联系列表", ListView.class);
        RouterLink decimal_conversion_link=new RouterLink("进制转换", Decimal_Conversion.class);

        listLink.setHighlightCondition(HighlightConditions.sameLocation());

        addToDrawer(new VerticalLayout(decimal_conversion_link,            
            new RouterLink("更改", ChangeView.class),listLink
        ));


    }
}
